package 单表查询;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class Demo01 {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.jdbc.Driver");
        String url = "jdbc:mysql://localhost:3306/db_jdbc_demo?characterEncoding=utf8&useSSL=false&serverTimezone=UTC";
        String user = "root";
        String pass = "xiaotong123";
        Connection conn = DriverManager.getConnection(url,user,pass);
        String sql = "SELECT * from t_user";
        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery(sql);
        while (rs.next()){
            String username = rs.getString("username");
            String fullname = rs.getString("fullname");
            System.out.println(username+","+fullname);
        }
        rs.close();
        stmt.close();
        conn.close();
    }
}
